package se.hrbustrc.hlgshopping.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import se.hrbustrc.hlgshopping.interceptor.AuthInterceptor;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private AuthInterceptor authInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authInterceptor)
                .addPathPatterns("/api/**",
                        "/member/**",
                        "/order/**",
                        "/address/**",
                        "/sku/**",
                        "/product/**")
                .excludePathPatterns(
                        "/product/list",
                        "/product/{id}",
                        "/sku/product/{productId}",
                        "/alipay/**" // 添加这一行，排除所有以 /alipay 开头的请求
                );
    }

//    @Bean
//    public BCryptPasswordEncoder bCryptPasswordEncoder() {
//        return new BCryptPasswordEncoder();
//    }
}
